<?
/**
 * Register.php
 * 
 * Displays the registration form if the user needs to sign-up,
 * or lets the user know, if he's already logged in, that he
 * can't register another name.
 *
 */
include("include/session.php");
?>


<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="Description" content="Information about the Symposium on Racing & Gaming, presented by the University of Arizona Race Track Industry Program. Includes sponsors, exhibitors, panel sessions, award winners, photos, transcripts and presentations" />
    <meta name="Keywords" content="horseracing, horse racing, race track education, race horse, racehorse, greyhound tracks, horsetrack, thoroughbred racing, quarterhorse racing, horse breeding, pari-mutuel, parimutuel, equine education, greyhound racing, dog racing, harness racing, horse training, symposium on racing, multi-breed, racetrack industry, turf racing, rtip, gaming, betting, racetrack betting, University of Louisville, racetrack education, racetrack school, race track school, horseracing school, horseracing college, horse racing college, racetrack college, race track college, equine school, equine college, equine program, symposium on gaming" />
 
   <title>Symposium Login</title>
    <link href="css/rtip.css" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>

<div id="wrap">
    <div id="topbar">
	<a href="http://www.arizona.edu/" target="_blank"></a>
    </div>
    <div id="top">
        <div id="head_image"> </div>
    </div>

    <div id="page_head">
        <h2 id="left_head"> </h2>
        <h2 id="right_head"> </h2>

    </div>

<html>
<title>Registration Page</title>
<body>

<?
$err = false;
if(isset($_SESSION['userchange'])&& $_SESSION['userchange']) {
	$_POST['regid'] =  $_SESSION['userchange'];
	
}


/**
 * The user is already logged in, not allowed to register.
 */
if($session->logged_in && $session->isAdmin() ){?>
	<h1>Registration</h1><?
	$goodid = (isset($_POST['regid']) && $database->id2username($_POST['regid']) );
	if($err || $goodid ){
		$_SESSION['userchange'] = false;
		$userinfo = $database->getUserInfo($database->id2username($_POST['regid']));
		if($form->num_errors > 0){
			echo "<td><font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font></td>";
		}
		?>
		<form action="process.php" method="POST">
			<table id="users" align="left" border="0" cellspacing="0" cellpadding="3">
				<tr>
					<td>Username:</td>
					<td><input type="text" name="username" maxlength="30" value="<?
							if($form->value("username") == "")
								{ echo trim($userinfo['username']); }
							else{ echo $form->value("username"); }
						?>"></td>
					<td><? echo $form->error("username"); ?></td>
				</tr>
				<tr>
					<td>Password:</td>
					<td><input type="password" name="password" maxlength="30" value=""></td>
					<td><? echo $form->error("password"); ?></td>
				</tr>

				<tr>
					<td id="users">First Name:</td>
					<td id="users" ><input type="text" name="fname" maxlength="50" value="<?
							if($form->value("fname") == "")
								{ echo trim($userinfo['fname']); }
							else{ echo $form->value("fname"); }
						?>"></td>
					<td><? echo $form->error("fname"); ?></td>
				</tr>
				<tr>
					<td>Last Name:</td>
					<td><input type="text" name="lname" maxlength="50" value="<?
							if($form->value("lname") == "")
								{ echo $userinfo['lname']; }
							else{ echo $form->value("lname"); }
						?>"></td>
					<td><? echo $form->error("lname"); ?></td>
				</tr>
				<tr>
					<td>Organization:</td>
					<td><input type="text" name="organization" maxlength="50" value="<?
							if($form->value("organization") == "")
								{ echo $userinfo['organization']; }
							else{ echo $form->value("organization"); }
						?>"></td>
					<td><? echo $form->error("organization"); ?></td>
				</tr>
				<tr>
					<td>Website:</td>
					<td><input type="text" name="website" maxlength="50" value="<?
							if($form->value("website") == "")
								{ echo $userinfo['website']; }
							else{ echo $form->value("website"); }
						?>"></td>
					<td><? echo $form->error("website"); ?></td>
				</tr>
				<tr>
					<td>Phone Number:</td>
					<td><input type="text" name="phone" maxlength="50" value="<?
							if($form->value("phone") == "")
								{ echo $userinfo['phone']; }
							else{ echo $form->value("phone"); }
						?>" onkeydown="backspacerDOWN(this,event);" onkeyup="backspacerUP(this,event);" /></td>
					<td><? echo $form->error("phone"); ?></td>
				</tr>
				<tr>
					<td>Address:</td>
					<td><input type="text" name="address" maxlength="50" value="<?
							if($form->value("address") == "")
								{ echo $userinfo['address']; }
							else{ echo $form->value("address"); }
						?>"></td>
					<td><? echo $form->error("address"); ?></td>
				</tr>
				<tr>
					<td>Email:</td>
					<td><input type="text" name="email" maxlength="50" value="<?
							if($form->value("email") == "")
								{ echo $userinfo['email']; }
							else{ echo $form->value("email"); }
						?>"></td>
					<td><? echo $form->error("email"); ?></td>
				</tr>

				<tr>
					<td colspan="2" align="right">
						<input type="hidden" name="userid" value="<? echo $_POST['regid']; ?>">
						<input type="hidden" name="subchange" value="1">
						<input type="submit" value="Save Changes">
					</td>
				</tr>
				<tr>
					<td colspan="2" align="left"></td>
				</tr>
			</table>
		</form>
		<?
		
	} else { // used to get the persons id info
		$_SESSION['userchange'] = false;
		?>
		<form action="register.php" method="POST">
		<table align="center" border="0" cellspacing="0" cellpadding="3">
		<tr align="center" ><td>Id:</td><td><input type="text" name="regid" maxlength="30" value=""></td></tr>
		<tr><td colspan="2" align="center" ><input type="submit" value="Lookup"></td></tr>
		</table>
		</form>
	<?}
} else {
	?><a href="main.php">Back to Main</a><?
}

?>
</td></tr>
</table>
</div>
</body>
</html>
